﻿/*===================================================================================
	TASK 3:                                                                   {Arrays}
	Write a program that compares two char arrays lexicographically (letter by letter).    
=====================================================================================*/

using System;

class CompareTwoCharArraysLexicographically
{
    static void Main()
    {
        Console.Write("Enter First char array:");
        string firstArray = Console.ReadLine();

        Console.Write("Enter Second char array:");
        string secondArray = Console.ReadLine();

        int counter;
        string areEquals = "";

        if (firstArray.Length > secondArray.Length)
        {
            counter = secondArray.Length;
        }
        else 
        {
            counter = firstArray.Length;
        }

        for (int i = 0; i < counter; i++)
        {
            if (firstArray[i] == secondArray[i])
            {
                areEquals = "equals";
            }

            if ((firstArray[i] == secondArray[i]) && firstArray.Length > secondArray.Length)
            {
                areEquals = "second array is earlier in order";
                break;
            }

            if ((firstArray[i] == secondArray[i]) && firstArray.Length < secondArray.Length)
            {
                areEquals = "first array is earlier in order";
                break;
            }

            else if (firstArray[i] < secondArray[i])
            {
                areEquals = "first array is earlier in order";
                break;
            }

            else if (firstArray[i] > secondArray[i])
            {
                areEquals = "second array is earlier in order";
                break;
            }
        }
        Console.WriteLine();
        Console.WriteLine("{0}!", areEquals);
        Console.WriteLine();

    }
}

